﻿using ConsoleApp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Collections.Concurrent;

namespace ConsoleApp2
{

    class Program
    {

        static void Main(string[] args)
        {
            //new DelegateClass().Show();
            //new EventClass().Show();
            //new EventClassTest().Show();

            //不安全代码
            //new UnsafeTest().Show();

            ////JIT 和 调试
            //new DebugAndRelease().Show2();

            var students = AppDBData.GetDBMananyStudents().ToList();

            //var dic = new ConcurrentDictionary<string, int>();
            var dic = new Dictionary<string, int>();
            var time3 = DateTime.Now;
            Parallel.For(0, students.Count, (int pi) =>
            {
                var student = students[pi];
                dic.Add(student.id.ToString(), student.id);
                Thread.Sleep(1);
                students[pi].name = students[pi].name + "00";
            });
            var time4 = DateTime.Now;
            var ss = (time4 - time3).TotalMilliseconds;
            Console.WriteLine("-----------------" + ss);
            Console.WriteLine(dic.Count());
            Console.WriteLine("-----------------" );
            //foreach (var item in dic.Keys.OrderBy(g=>g).ToList())
            //{
            //    Console.WriteLine(item);

            //}

            Console.ReadKey();
        }

    }
}
